package com.lsl.facade_pattern.example;

/**
 * description:
 *
 * @author: liushengli
 * data: 2022/11/30
 */

/**
 * 影院类---外观类
 */
public class HomeTheaterFacade {

    //定义各个子系统对象
    private PopCorn popCorn;
    private DvdPlayer dvdPlayer;
    private Projector projector;
    private Scree scree;
    private Stereo stereo;
    private TheaterLight theaterLight;

    //构造器
    public HomeTheaterFacade() {
        this.popCorn = PopCorn.getInstance();
        this.dvdPlayer = DvdPlayer.getInstance();
        this.projector = Projector.getInstance();
        this.scree = Scree.getInstance();
        this.stereo = Stereo.getInstance();
        this.theaterLight = TheaterLight.getInstance();
    }

    //操作分4步
    //准备过程中的几个步骤，按照顺序统一在ready中调用
    public void ready() {
        popCorn.on();
        popCorn.pop();
        scree.down();
        projector.on();
        stereo.on();
        dvdPlayer.on();
        theaterLight.dim();
    }

    //播放接口
    public void play() {
        dvdPlayer.play();
    }

    //暂停接口
    public void pause() {
        dvdPlayer.pause();
    }

    //结束流程与准备流程相反
    public void end() {
        popCorn.off();
        theaterLight.bright();
        scree.up();
        projector.off();
        stereo.off();
        dvdPlayer.off();

    }
}